<?php

namespace Plugins\AdminBasic\Http\Admin\Service;

use App\Util\DBHelper;
use App\Util\Helper;
use Hyperf\DbConnection\Db;
use Sc\Util\ImitateAopProxy\AopProxyTrait;

/**
 * Class DevAuxService
 */
class DevAuxService
{
    use AopProxyTrait;

    /**
     * 获取表
     *
     * @param string $table
     * @param bool   $hasPrefix
     *
     * @return string
     */
    public static function getTable(string $table, bool $hasPrefix = true): string
    {
        return DBHelper::getTableName($table, $hasPrefix);
    }


    /**
     * @param string $table
     *
     * @return array
     */
    public function getFields(string $table): array
    {
        return DBHelper::getFields($table);
    }

    /**
     * @param string $table
     *
     * @return array
     */
    public function getTableInfo(string $table): array
    {
        return DBHelper::getTableInfo($table);
    }

    /**
     * 获取所有表格信息
     *
     * @return array
     */
    public function getAllTableInfo(): array
    {
        return DBHelper::getAllTableInfo();
    }

    /**\
     * 获取创建表的SQL
     *
     * @param string $table
     *
     * @return mixed
     */
    public function getCreateSql(string $table): mixed
    {
        return DBHelper::getTableCreateSql($table);
    }

    /**
     * 创建时支持的表单
     *
     * @return array[]
     */
    public static function supportForm(): array
    {
        return [
            ['label' => '隐藏域', 'value' => 'hidden'],
            ['label' => '文本', 'value' => 'text'],
            ['label' => '日期时间', 'value' => 'datetime'],
            ['label' => '图片', 'value' => 'image'],
            ['label' => '开关', 'value' => 'switch'],
            ['label' => '单选', 'value' => 'radio'],
            ['label' => '多选', 'value' => 'checkbox'],
            ['label' => '下拉', 'value' => 'select'],
            ['label' => '文本域', 'value' => 'textarea'],
            ['label' => '富文本', 'value' => 'editor'],
            ['label' => '上传', 'value' => 'upload'],
        ];
    }
}